package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.Answer;
import cn.wolfcode.luowowo.article.domain.Ask;
import cn.wolfcode.luowowo.article.query.AskQuery;
import cn.wolfcode.luowowo.article.service.IAskService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/ask")
public class AskController {
    @Reference
    private IAskService askService;

    // 查询问题列表
    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") AskQuery qo) {
        qo.setStatus(null);
        model.addAttribute("pageInfo", askService.query(qo));

        return "/community/Asklist";
    }

    @RequestMapping("/upByStatus")
    @ResponseBody
    public AjaxResult upByStatus( Ask ask) {
        AjaxResult result = new AjaxResult();
        try {
            askService.upByStatus(ask);
        }catch (Exception e){
            result.setSuccess(false);
            result.setMsg(e.getMessage());
        }
        return result;
    }


}
